package com.kasax.router_compiler;

import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic;

public class MessagerPrintUtls {
    private static Messager mMessager;

    public static void inject(Messager messager) {
        mMessager = messager;
    }

    public static void print(String message, Object... args) {
        print(message, null, args);
    }

    public static void print(Element element) {
        print("", element);
    }

    public static void print(String message, Element element, Object... args) {
        if (args != null && args.length > 0) {
            message = String.format(message, args);
        }
        if (element != null) {
            mMessager.printMessage(Diagnostic.Kind.NOTE, message, element);
        } else {
            mMessager.printMessage(Diagnostic.Kind.NOTE, message);
        }
    }
}